﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Services4KouDai;
using Services4KouDai.Models;
using Services4KouDai.Services;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;

namespace ServiceTest
{
    [TestClass]
    public class KouDaiServiceFixture
    {
        [TestMethod]
        public async Task GetHoneyWallTest()
        {
            App.Current.Init();

            var honeyService = App.Current.AppContainer.Resolve<IHoneyService>();
            ServiceRespInfo serviceInfo = await honeyService.GetHoneyWall("Combine_Default", 0, 36);

            Assert.IsTrue(serviceInfo.IsSuccess);

            List<HoneyEntity> items = (List<HoneyEntity>)serviceInfo.RespData;

            Assert.AreEqual(items.Count, 36);
        }

        [TestMethod]
        public async Task GetGroupCombineTest()
        {
            App.Current.Init();

            var groupCombineService = App.Current.AppContainer.Resolve<IGroupCombineService>();
            ServiceRespInfo serviceInfo = await groupCombineService.GetGroupCombineList(Platform.WIN8);

            Assert.IsTrue(serviceInfo.IsSuccess);

            List<GroupCombineEntity> items = (List<GroupCombineEntity>)serviceInfo.RespData;

            Assert.AreEqual(items.Count, 46);
        }


        [TestMethod]
        public async Task GetGoodShopListTest()
        {
            App.Current.Init();

            var goodShopListService = App.Current.AppContainer.Resolve<IGoodShopListService>();
            int groupType = 0;
            string groupId = "Combine_7dac684bda0b38a21c6f18895848ccc6";
            ServiceRespInfo serviceInfo = await goodShopListService.GetGoodShopList(groupType, groupId, 10);

            Assert.IsTrue(serviceInfo.IsSuccess);

            List<ShopEntity> items = (List<ShopEntity>)serviceInfo.RespData;

            //TODO 这个地方并没有根据数量去请求
            Assert.AreEqual(items.Count, 16);
        }

        [TestMethod]
        public async Task GetGoodsDetailTest()
        {
            App.Current.Init();

            var goodsDetailService = App.Current.AppContainer.Resolve<IGoodsDetailService>();

            ServiceRespInfo serviceInfo = await goodsDetailService.GetGoodsDetail("taobao17415189224",Platform.WIN8);

            Assert.IsTrue(serviceInfo.IsSuccess);

        }
        
    }
}
